﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Users
    {
           
            public long ID{get;set;}
            public string UserGuidID{get;set;}
            [Description("Tài khoản")]
            public string UserName { get; set; }
            public string PassWord{get;set;}
            public long StaffID { get; set; }
            public bool Lock { get; set; }
            public string Description { get; set; }
            public DateTime StartDate { get; set; }
            public DateTime Endate { get; set; }
            public string Email { get; set; }
            public string PassEmail { get; set; }
            public string ModuleExt { get; set; }
            public string RoleExt { get; set; }
         
        public Users()
        {       
                            UserGuidID =Guid.NewGuid().ToString();
                            UserName ="";
                            StartDate = DateTime.Now;
                            Endate = DateTime.Now.AddMonths(12);
                            PassWord ="";   
                            ModuleExt = "";
                            RoleExt = "";
        }
        
       static Users DynamicCast<T>(object row_data, object row_header) where T : Users
       {
           // row_data : DataRow
           // row_header : DataColumnCollection 
           Users ret = new Users();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                      case  "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "UserGuidID":
                        ret.UserGuidID = ConvertObject.ToString(dt[column]);
                       break;
                      case  "UserName":
                        ret.UserName = ConvertObject.ToString(dt[column]);
                       break;
                      case  "PassWord":
                        ret.PassWord = ConvertObject.ToString(dt[column]);
                       break;
                      case "StaffID":
                        ret.StaffID = ConvertObject.ToLong(dt[column]);
                       break;
                   case "Module":
                       ret.ModuleExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "Role":
                       ret.RoleExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "Lock":
                       ret.Lock = ConvertObject.ToBool(dt[column]);break;
                   case "Description":
                       ret.Description = ConvertObject.ToString(dt[column]); break;
                   case "StartDate":
                       ret.StartDate = ConvertObject.ToDateTime(dt[column]); break;
                   case "Endate":
                       ret.Endate = ConvertObject.ToDateTime(dt[column]); break;
                   case "Email":
                       ret.Email = ConvertObject.ToString(dt[column]);break;
                   case "PassEmail":
                       ret.PassEmail = ConvertObject.ToString(dt[column]); break;
                   default:
                       break; 
               }
           }

           return ret;
       }
        
    }
}
